

package ro.ase.catalog.security.dao.hibernate;

import org.hibernate.criterion.DetachedCriteria;
import org.hibernate.criterion.Expression;
import ro.ase.catalog.beans.AclClass;
import ro.ase.catalog.dao.hibernate.GenericDAOImpl;
import ro.ase.catalog.security.dao.IAclClassDAO;

import java.util.List;

/**
 *
 */
public class AclClassDAOImpl extends GenericDAOImpl<AclClass, Long>  implements IAclClassDAO {


    @SuppressWarnings("unchecked")
    public AclClass findByClass(String cls) {
        DetachedCriteria criteria = DetachedCriteria.forClass(AclClass.class);
        criteria.add(Expression.eq("cls", cls));

        List<AclClass> list = getHibernateTemplate().findByCriteria(criteria);
        if (!list.isEmpty()) {
            return list.get(0);
        }
        return null;
    }

}
